package com.car.web.admin;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@WebServlet("/admin/logOUT")
public class AdminLoginOut extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
        //一次会话过程,使用session保存管理员的登录信息,思路: 销毁session或者将session中的用户信息移除
        HttpSession session = request.getSession();
        session.invalidate();
        //重定向到登录页面
        response.sendRedirect(request.getContextPath()+"../log/log.jsp");
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
        doPost(request, response);
    }
}
